package developer.zyk.global.common;

import lombok.Data;

@Data
public class Result<T> {

    private static final int success = 200;

    private int code = success;

    private String message;

    private T data;


    public static Result<Boolean> success() {
        Result<Boolean> result = new Result<>();
        result.setCode(success);
        return result;
    }

    public static <T> Result<T> success(T t) {
        Result<T> result = new Result<>();
        result.setCode(success);
        result.setData(t);
        return result;
    }

    public static <T> Result<T> success(T t, String message) {
        Result<T> result = new Result<>();
        result.setCode(success);
        result.setData(t);
        result.setMessage(message);
        return result;
    }


    public static <T> Result<T> fail(int code, String message) {
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }


}
